package Behavioral.Observer.polling.waitNotify;

//输出线程
public class Output implements Runnable {
    Resource r;
    public Output(Resource r) {
        this.r = r;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (r) {
                System.out.println("--------------" + r.name + "是" + r.sex);
                r.notify();
                try {
                    r.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
